/**
 * 
 */
package com.effectiv.gooruda.interceptor;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.extern.slf4j.Slf4j;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @author Dhrubo
 *
 */
@Slf4j
public class TabHighlightingInterceptor extends HandlerInterceptorAdapter{
	
	private Map<String,String> requestMap;
	
	

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		
		
		log.debug("Request URI - {}", request.getRequestURI());
		
		String uri = request.getRequestURI();
		
		if(requestMap.containsKey(uri)){
			modelAndView.addObject("nav", requestMap.get(uri));
		}
		
		
	}
	
	public void init(){
		requestMap = new HashMap<String,String>();
		requestMap.put("/req1/editproject", "project");
		requestMap.put("/req1/newproject", "project");
		requestMap.put("/req1/listprojects", "project");
		requestMap.put("/req1/newprojectuser", "project");
		requestMap.put("/req1/updatemanager", "project");
		
		requestMap.put("/req1/listusecases", "uc");
		requestMap.put("/req1/viewusecase", "uc");
		requestMap.put("/req1/editusecase", "uc");
		
		requestMap.put("/req1/home", "home");
		
	}
}
